﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using MovieReview.Models;

namespace MovieReviews
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            //GET api/movie or GET api/movie/Inception
            config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{moviename}",
            defaults: new { moviename = RouteParameter.Optional }
            );

            //GET api/movie?rating=8.9
            config.Routes.MapHttpRoute(
            name: "RatingApi",
            routeTemplate: "api/{controller}/{rating}",
            defaults: new { rating = RouteParameter.Optional }
            );

            //GET api/movie?date=01.01.2014
            config.Routes.MapHttpRoute(
            name: "DateApi",
            routeTemplate: "api/{controller}/{date}",
            defaults: new { date = RouteParameter.Optional }
            );

            //GET api/movie?user=Alice
            config.Routes.MapHttpRoute(
            name: "UserApi",
            routeTemplate: "api/{controller}/{user}",
            defaults: new { user = RouteParameter.Optional }
            );

            //GET api/movie/Inception?user=Alice
            config.Routes.MapHttpRoute(
            name: "NameAndUserApi",
            routeTemplate: "api/{controller}/{moviename}/{user}",
            defaults: new { user = RouteParameter.Optional }
            );
        }
    }
}
